<dom-module id="cc-sprite-inspector">
  <template>
    <style>
	    editor-button {
        margin-left: 5px;
      }

      .line {
        border-bottom: 1px solid #666;
        margin: 0px 1px 6px 15px;
      }
    </style>
    <!--<editor-custom-prop title="[[_T('COMPONENT.sprite.atlas')]]" name="Atlas">
      <div class="layout horizontal center">
        <fire-asset class="flex-1" value="{{target._atlas.value.uuid}}" type="sprite-atlas"></fire-asset>
        <editor-button title="选择" class="small" on-click="_selectAtlas">选择</editor-button>
      </div>
    </editor-custom-prop>-->
    <editor-custom-prop title="[[_T('COMPONENT.sprite.sprite_frame')]]" name="Sprite Frame">
      <div class="layout horizontal center">
        <fire-asset class="flex-1" value="{{target.spriteFrame}}" path="spriteFrame" type="sprite-frame"></fire-asset>
        <!--<editor-button title="编辑" class="small" on-click="_editSprite">编辑</editor-button>-->
      </div>
    </editor-custom-prop>
    <div class="line"></div>
    <editor-prop prop="{{target.srcBlendFactor}}"></editor-prop>
    <editor-prop prop="{{target.dstBlendFactor}}"></editor-prop>
  </template>
  <script>
    'use strict';

    Editor.polymerElement({
      properties: {
        target: {
          type: Object,
          value: null,
          notify: true,
        },
      },

      _resizeToOriginal: function () {
        if(!this.target.sprite.value.uuid) {
          return;
        }
        var nodeuuid = this.target.node.uuid;
        Editor.assetdb.queryMetaInfoByUuid( this.target.sprite.value.uuid, function (err,info) {
          let meta = JSON.parse(info.json);
          Editor.Ipc.sendToPanel('scene', 'scene:set-property', {
            id: nodeuuid,
            path: 'size',
            type: 'cc.Size',
            value: {width: meta.width, height: meta.height},
            isSubProp: false,
          });
        });
      },

      _selectAtlas: function () {
        console.log("TO DO Select Atals Panel");
      },

      _editSprite: function () {
        Editor.Panel.open('sprite-editor', {
          uuid: this.target.spriteFrame.value.uuid
        });
      },

      _isFilledType: function(type) {
        return type === cc.Scale9Sprite.RenderingType.FILLED;
      },

      _isRadialFilled: function(fillType) {
        return fillType === cc.Scale9Sprite.FillType.RADIAL;
      },
    });
  </script>
</dom-module>